<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ include file="/WEB-INF/views/shared/taglib.jsp"%>
<%
	request.setAttribute("title", "资讯详情");
%>
<%@ include file="/WEB-INF/views/shared/master/weContentHeader.jsp"%>
<style type="text/css">	
	.thenews{
		padding:0px 20px;
		margin-top:15px;
		border-bottom: 4px solid #eee; 		
	}
	
	.thenews>a>p{
		margin: 17px 0px;
		font-size: 18px;
		color:#afafaf;
		font-weight: bold;		
	}
	
	.info_tittle{
		margin: 20px 15px;
	}
	.titlehidden{
		-webkit-line-clamp: 3;
	}
	.totalhide{
		overflow:hidden;
		text-overflow:ellipsis;	
		display:-webkit-box;
		-webkit-box-orient: vertical;	
	}
	.titlehide{
		-webkit-line-clamp: 1;
	}
	
	.info_contents{
		line-height: 1.7;
		margin: 0px 18px;
		padding-bottom: 10px;
	}
	
	.like{
		float: right;
		font-size: 0.7rem;
	}
	
	.todaynews{
		padding:0px 20px;
		margin-top:15px;
		border-bottom: 4px solid #eee; 
		height: 100px;
		color:black;
	}
	
	.todaynews>div{
		padding:6px
	}
	.todaynews>div>img{
		height: 70px;
	}
	
	.aboutother{
		padding: 20px 10px;
		font-size: 20px;
		color:#afafaf;
		border-bottom: 3px solid #eee; 
	}
	
	.type{
		color:#afafaf;
		margin-top: 15px;
	}
	.eyes{
		width:30px;
		padding-top: 3px;
	}
	.msg{
		text-align: center;
		margin: 20px 0px;
		color:#afafaf;
	}

	.info_contents img{
		width:16rem;
		height:8rem;
	}
	.info_contents{
		word-wrap: break-word;
	}
	.smallimg{
		width: 5.5rem;
	}
</style>
<%@ include file="/WEB-INF/views/shared/master/weTitle.jsp"%>
<div class="goback" data-back-href="<c:url value='/wechat/share/cloudSharing'/>"></div>	
<input type="hidden" id="id" value="${info.id}" data-type="infoType"/>
<input type="hidden" id="fromWhere" value="${fromWhere}"/>
<input type="hidden" id="infoThumbnailId" value="${info.infoThumbnailId}"/>

<div>
	<div class="info_tittle">
		<div class="weui-flex ">
			<div class="weui-flex__item " style="flex-grow:6;justify-content: center;align-items:center;text-align: center; " id="test">
				<h2 class="titlehidden totalhide" style="padding-right: 10px" >${info.infoTitle}</h2>
			</div>										
			<%-- <div class="weui-flex__item" style="flex-grow:1">
				<img class="like starfill" style="width:25px;" src="<c:url value='/images/we/informationDetails/star1.png'/>" />
				<input type="hidden" class="thecollection" value="${like}"/>
			</div> --%>
		</div>	
		<p style="color: #afafaf;font-size: 14px;margin-top: 10px">
			<span>作者：${info.infoAuthor}</span>
			<span style="margin-left: 35px">
				<fmt:formatDate value="${info.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>			
			</span>
		</p>
	</div>
	<div class="info_contents" style="padding: 0px 5px">${info.infoContent}</div>
</div>

		
<div style="width:100%;height:20px;background-color: #ebebeb;margin-top: 10px;"></div>
	
<div>
	<h3 class="aboutother">相关推荐</h3>
	<div class="msg" >
		<img class=""  src="<c:url value='/images/we/cloudSharing/null.png'/>" />
		<p class="p_msg">${msg}</p>
	</div>
	<div>
		<c:forEach items="${shareInfos}" var="shareInfo">			
			<a href="<c:url value='/wechat/share/informationDetails?key=${shareInfo.id}&fromWhere=informationDetails' />">
				<div class="weui-flex todaynews">
					<div class="weui-flex__item " style="flex-grow:1;justify-content: center;align-items:center; " id="test">
						<c:if test="${shareInfo.infoThumbnailId!=null && shareInfo.infoThumbnailId!=''}">
							<img class="smallimg" src="${tfn:getFileUrl(shareInfo.infoThumbnailId)}" style="height: 70px;width:100%"/> 
						</c:if>
						<c:if test="${shareInfo.infoThumbnailId ==null || shareInfo.infoThumbnailId==''}">
							<img class="smallimg" style="width:100%;display: block;" src="<c:url value='/images/we/index/WechatIMG8.jpeg' />" />
						</c:if>
					</div>
						
					<div class="weui-flex__item" style="flex-grow:2">
						<p class="titlehide totalhide">${shareInfo.infoTitle}</p>
						<p class="type">
							<span style="float: right;">
								<span class="like">&nbsp;&nbsp;&nbsp;${shareInfo.viewTimes.viewtimes}</span>
								<img class="like" style="width:16px;display: block;padding-top:0.2rem " src="<c:url value='/images/we/cloudSharing/eye.png'/>" />								
							</span>							
						</p>
					</div>
				</div>
			</a>
		</c:forEach>
	</div>
</div>	
		
<%@ include file="/WEB-INF/views/shared/scripts/jquery.jsp"%>
<%@ include file="/WEB-INF/views/shared/scripts/jqweui.jsp"%>
<%@ include file="/WEB-INF/views/shared/scripts/tabmob.jsp"%>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>

<script type="text/javascript">
	function goback(){
		var fromWhere = $("#fromWhere").val();
		if(fromWhere=="cloudSharing"){
			window.location.href=$.getVirtualPath()+"/wechat/share/cloudSharing";
		}else if(fromWhere=="collectIndex"){
			window.location.href=$.getVirtualPath()+"/wechat/cust/colAndFoot/collectIndex";
		}else if(fromWhere=="informationDetails"||fromWhere=="moreInformation"){
			window.history.go(-1);
		}
	}

	$(function(){
		$(".hideimg").hide();
		/* 全局变量id和类型 */
		var $input = $("#id");
		var type = $input.data("type");
		var thingId = $input.val();
		
		/*在足迹表中插入一条数据 */
		var action = $.getVirtualPath()+"/wechat/allFootprint/addFootprint?type="+type+"&thingId="+thingId;
		$.getTextPost(action);
		
		/*根据初始状态展示收藏状态	*/
		var state;
		
		var url = $.getVirtualPath()+"/wechat/allCollect/isCollect?type="+type+"&thingId="+thingId;
		var result = $.getTextPost(url);
		if(result=="true"){
			$(".starfill").attr("src","<c:url value='/images/we/informationDetails/star2.png'/>");
			state = 0;
		}else{
			$(".starfill").attr("src","<c:url value='/images/we/informationDetails/star1.png'/>");
			state = 1;
		}
		
		//收藏
		$(".starfill").on("click",function () {
			if(state==0){
				//取消收藏
				var url = $.getVirtualPath()+"/wechat/allCollect/delete?type="+type+"&thingId="+thingId;
				var result = $.getTextPost(url);
				if(result="true"){
					state = 1;
					$(".starfill").attr("src","<c:url value='/images/we/informationDetails/star1.png'/>");
				}else{
					$.toast("取消失败");
					state = 0;
				}
				
			}else if (state==1) {			
				//添加收藏
				var url = $.getVirtualPath()+"/wechat/allCollect/addCollect?type="+type+"&thingId="+thingId;
				var result = $.getTextPost(url);
				if(result="true"){
					state=0;
					$(".starfill").attr("src","<c:url value='/images/we/informationDetails/star2.png'/>");
				}else{
					$.toast("收藏失败");
				}
			}
			
		});
	
		//有没有更多
		if($(".p_msg").html()==""){
			$(".msg").hide();
		}else{
			$(".msg").show();
		}
		
/* ------------------------------微信分享-------------------------- */	
		var $desc ="${info.infoTitle}";
		var $key = "${info.id}";
		var $imgUrl = "";

		if($.isNull($("#infoThumbnailId").val())){
			$imgUrl = "http://www.putiyoli.net/ares/images/logo.png";
		}else{
			$imgUrl = "${tfn:getFileUrl(info.infoThumbnailId)}";
			console.log($imgUrl);
		}
		
		var url=$.getVirtualPath()+"/wechat/cust/personCenter/shareSignature";
		var href=encodeURIComponent(window.location.href);
		console.log(href);
		var resultJson=$.getJsonPost(url,"href="+href);
		console.log(resultJson);

		var config={
				debug: false,
			  	appId: resultJson.jsapiSignature.appId,// 公众号的唯一标识
			  	timestamp: resultJson.jsapiSignature.timestamp,// 生成签名的时间戳
			  	nonceStr: resultJson.jsapiSignature.nonceStr,// 生成签名的随机串
			  	signature: resultJson.jsapiSignature.signature,// 签名
			  	jsApiList: ['onMenuShareAppMessage','onMenuShareTimeline']
			}
		wx.config(config);
		// 微信事件
		wx.ready(function () {
			// 分享朋友
			wx.onMenuShareAppMessage({
			    title: "普天永利-资讯",//resultJson.linkName+'的邀请码',
			    desc:  $desc,
			    link:  window.location.href+"?key="+$key+"&fromWhere=cloudSharing",
			    imgUrl: "http://www.putiyoli.net/ares/images/logo.png",
			    success: function () {
					console.log(arguments);
			    },error:function(){
			    }
			});
			console.log(config);
			//分享到朋友圈
			wx.onMenuShareTimeline({
				title: "普天永利-资讯",
			    link:  window.location.href+"?key="+$key+"&fromWhere=cloudSharing",
			    imgUrl: "http://www.putiyoli.net/ares/images/logo.png",
				success: function (res) {
				}
			});
			// 微信错误处理机制
			wx.error(function (res) {
				console.log(res.errMsg);
			});
		});	
	});		

</script>


<%@ include file="/WEB-INF/views/shared/master/weContentFooter.jsp"%>
